<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('influencers', function (Blueprint $table) {
            $table->id();
            $table->string('name')->comment('网红名称');
            $table->integer('platform_id')->constrained()->onDelete('cascade');
            $table->string('platform_user_id')->comment('平台用户ID');
            $table->string('avatar')->nullable()->comment('头像URL');
            $table->text('description')->nullable()->comment('网红简介');
            $table->string('contact_info')->nullable()->comment('联系方式');
            $table->bigInteger('follower_count')->default(0)->comment('粉丝数');
            $table->decimal('score', 3, 1)->default(5.0)->comment('评分');
            $table->integer('report_count')->default(0)->comment('举报次数');
            $table->boolean('is_blacklisted')->default(false)->comment('是否黑名单');
            $table->timestamps();
            $table->softDeletes();

            // 创建联合唯一索引
            $table->unique(['platform_id', 'platform_user_id']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('influencers');
    }
}; 